﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Net;
using System.Diagnostics;

namespace NTweet.HttpService {
	public sealed class HttpRequest : IHttpRequest {
		HttpWebRequest request;

		public HttpRequest(HttpWebRequest request) {
			this.request = request;
		}

		public Uri Uri { get { return request.RequestUri; } }

		public IHttpResponse GetResponse() {
			Debug.WriteLine("Get Response: " + Uri, "HTTP");
			var response = new HttpResponse((HttpWebResponse)request.GetResponse());
			Debug.WriteLine("Response Status: " + response.StatusCode, "HTTP");
			return response;
		}
		public IAsyncResult BeginGetResponse(AsyncCallback callback, object state) {
			return request.BeginGetResponse(callback, state);
		}
		public IHttpResponse EndGetResponse(IAsyncResult asyncResult) {
			return new HttpResponse((HttpWebResponse)request.EndGetResponse(asyncResult));
		}

		public ICredentials Credentials {
			get { return request.Credentials; }
			set { request.Credentials = value; }
		}

		public CookieContainer CookieContainer {
			get { return request.CookieContainer; }
			set { request.CookieContainer = value; }
		}
	}
}
